import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
 **/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true},
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/statistics/payment',
    hidden: true
  },
  {
    path: '/statistics',
    component: Layout,
    meta: { title: '统计', icon: 'fa-bar-chart' },
    children: [
      {
        path: 'payment',
        component: () => import('@/views/statistics/payment'),
        meta: { title: '财务统计', icon: '' }
      },
      {
        path: 'parcel',
        component: () => import('@/views/statistics/parcel'),
        meta: { title: '包裹统计', icon: '' }
      },
      {
        path: 'commodity',
        component: () => import('@/views/statistics/commodity'),
        meta: { title: '产品销售统计', icon: '' }
      },
    ]
  },
  {
    path: '/consumers',
    component: Layout,
    meta: { title: '客户管理', icon: 'fa-users' },
    children: [
      {
        path: 'customer',
        component: () => import('@/views/consumers/customer'),
        meta: { title: '客户信息', icon: '' }
      },
      {
        path: 'consigneebook',
        component: () => import('@/views/consumers/consigneebook'),
        meta: { title: '收件人信息', icon: '' }
      },
      {
        path: 'idcard',
        component: () => import('@/views/consumers/idcard'),
        meta: { title: '身份证管理', icon: '' }
      },
    ]
  },
  {
    path: '/business',
    component: Layout,
    meta: { title: '业务管理', icon: 'fa-recycle' },/**fa-object-ungroup、fa-sitemap***/
    children: [
      {
        path: 'waybill',
        component: () => import('@/views/business/waybill'),
        meta: { title: '运单列表', icon: '' }
      },
      {
        path: 'sale',
        component: () => import('@/views/business/sale'),
        meta: { title: '销售列表', icon: '' }
      },
    ]
  },
  {
    path: '/finances',
    component: Layout,
    meta: { title: '财务管理', icon: 'fa-rmb' },
    children: [
      {
        path: 'invoice',
        component: () => import('@/views/finances/invoice'),
        meta: { title: '收据', icon: '' }
      },
      {
        path: 'payment',
        component: () => import('@/views/finances/payment'),
        meta: { title: '收款统计', icon: '' }
      },
      {
        path: 'charge',
        component: () => import('@/views/finances/charge'),
        meta: { title: '客户充值', icon: '' }
      },
      {
        path: 'point',
        component: () => import('@/views/finances/point'),
        meta: { title: '积分', icon: '' }
      },
    ]
  },
  {
    path: '/parts',
    component: Layout,
    redirect: '/parts/mailfree',
    meta: { title: '产品库存管理', icon: 'fa-cubes' },/**fa-th-large***/
    children: [
      {
        path: 'mailfree',
        component: () => import('@/views/parts/mailfree'),
        meta: { title: '产品库', icon: '' },
        children: [
          {
            path: 'goodstype',
            component: () => import('@/views/parts/mailfree/goodstype'),
            meta: { title: '商品分类', icon: '' }
          },
          {
            path: 'freegoods',
            component: () => import('@/views/parts/mailfree/freegoods'),
            meta: { title: '包邮商品', icon: '' }
          },
          {
            path: 'helpgoods',
            component: () => import('@/views/parts/mailfree/helpgoods'),
            meta: { title: '代购商品', icon: '' }
          },
          {
            path: 'selfbuygoods',
            component: () => import('@/views/parts/mailfree/selfbuygoods'),
            meta: { title: '自购商品', icon: '' }
          },
        ]
      },
      {
        path: 'purchase',
        component: () => import('@/views/parts/mailfree/purchase'),
        meta: { title: '零售预购单', icon: '' }
      },{
        path: 'storage',
        component: () => import('@/views/parts/components/bookingSheet'),
        meta: { title: '零售采购单', icon: '' }
      },
    ]
  },
  {
    path: '/intermodals',
    component: Layout,
    meta: { title: '物流设置', icon: 'fa-plane' },
    children: [
      {
        path: 'channel',
        component: () => import('@/views/intermodals/channel'),
        meta: { title: '发货渠道', icon: '' }
      },
      {
        path: 'batch',
        component: () => import('@/views/intermodals/batch'),
        meta: { title: '发货批次', icon: '' }
      },
      {
        path: 'express',
        component: () => import('@/views/intermodals/express'),
        meta: { title: '联运公司', icon: '' }
      },
      {
        path: 'api',
        component: () => import('@/views/intermodals/api'),
        meta: { title: '联运API接口', icon: '' }
      },
    ]
  },
  {
    path: '/baseconfig',
    component: Layout,
    meta: { title: '基础设置', icon: 'fa-wrench' },
    children: [
      {
        path: 'store',
        component: () => import('@/views/baseconfig/store'),
        meta: { title: '门店管理', icon: '' }
      },
      {
        path: 'postage',
        component: () => import('@/views/baseconfig/postage'),
        meta: { title: '商品收费类型', icon: '' }
      },
      {
        path: 'wordpoint',
        component: () => import('@/views/baseconfig/wordpoint'),
        meta: { title: '包裹状态', icon: '' }
      },
      {
        path: 'dictionary',
        component: () => import('@/views/baseconfig/dictionary'),
        meta: { title: '收款方式', icon: '' }
      },
    ]
  },
  {
    path: '/communication',
    component: Layout,
    meta: { title: '基础设置', icon: 'fa-globe' },
    children: [
      {
        path: 'notice',
        component: () => import('@/views/communication/notice'),
        meta: { title: '内部通讯', icon: '' }
      },
    ]
  },
  {
    path: '/wxapp',
    component: Layout,
    meta: { title: '小程序', icon: 'fa-wechat' },
    children: [
      {
        path: 'banner',
        component: () => import('@/views/wx/banner'),
        meta: { title: '广告管理', icon: '' }
      }, {
        path: 'goodslist',
        component: () => import('@/views/wx/goods'),
        meta: { title: '商品列表', icon: '' }
      },
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
